﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1Command;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_DangKyHoaDon : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("C1DockingTab1")]
        private C1DockingTab _C1DockingTab1;
        [AccessedThroughProperty("C1DockingTabPage1")]
        private C1DockingTabPage _C1DockingTabPage1;
        [AccessedThroughProperty("CboLoaiHoaDon")]
        private ComboBox _CboLoaiHoaDon;
        [AccessedThroughProperty("CboMauHoaDon")]
        private ComboBox _CboMauHoaDon;
        [AccessedThroughProperty("CboSoKiHieu")]
        private ComboBox _CboSoKiHieu;
        [AccessedThroughProperty("CKSoDuDK")]
        private CheckBox _CKSoDuDK;
        [AccessedThroughProperty("CmdChon")]
        private Button _CmdChon;
        [AccessedThroughProperty("CmdThoat")]
        private Button _CmdThoat;
        [AccessedThroughProperty("dtpNgayBDSD")]
        private DateTimePicker _dtpNgayBDSD;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label3")]
        private Label _Label3;
        [AccessedThroughProperty("Label4")]
        private Label _Label4;
        [AccessedThroughProperty("Label5")]
        private Label _Label5;
        [AccessedThroughProperty("Label6")]
        private Label _Label6;
        [AccessedThroughProperty("Label7")]
        private Label _Label7;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("RadSau")]
        private RadioButton _RadSau;
        [AccessedThroughProperty("RadTruoc")]
        private RadioButton _RadTruoc;
        [AccessedThroughProperty("updDenSo")]
        private NumericUpDown _updDenSo;
        [AccessedThroughProperty("updSoLuong")]
        private NumericUpDown _updSoLuong;
        [AccessedThroughProperty("updTuSo")]
        private NumericUpDown _updTuSo;
        private IContainer components;
        private clsDangKyHoaDon objDKHD;
        private DataTable pData;
        private string strNgayKT;

        public Frm_DangKyHoaDon()
        {
            base.Load += new EventHandler(this.Frm_DangKyHoaDon_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.pData = new DataTable();
            this.objDKHD = new clsDangKyHoaDon();
            this.InitializeComponent();
        }

        private void CboLoaiHoaDon_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.CboMauHoaDon.Focus();
            if (this.CboLoaiHoaDon.SelectedIndex > 0)
            {
                BuildComboModule.BuildCombo(this.CboMauHoaDon, modGeneral.ListDanhMuc.MauHoaDon, true, "KhoaLoaiHoaDonIn = '" + this.CboLoaiHoaDon.SelectedValue.ToString().Trim() + "'", "");
            }
            else
            {
                this.CboMauHoaDon.DataSource = this.pData;
                this.CboMauHoaDon.DisplayMember = "Ten";
                this.CboMauHoaDon.ValueMember = "Ma";
            }
        }

        private void CboMauHoaDon_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.CboSoKiHieu.Focus();
            if (this.CboLoaiHoaDon.SelectedIndex > 0)
            {
                BuildComboModule.BuildCombo(this.CboSoKiHieu, modGeneral.ListDanhMuc.SoKiHieu, true, "MauHoaDOn = '" + this.CboMauHoaDon.SelectedValue.ToString().Trim() + "'", "");
            }
            else
            {
                this.CboMauHoaDon.DataSource = this.pData;
                this.CboMauHoaDon.DisplayMember = "Ten";
                this.CboMauHoaDon.ValueMember = "Ma";
            }
        }

        private void CboSoKiHieu_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.dtpNgayBDSD.Focus();
            if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(LVYModule.ReturnIfNull(this.CboSoKiHieu.SelectedValue.ToString().Trim(), "", modGeneral.TypeOfValue.Nothing), "", false))
            {
                this.updTuSo.Enabled = false;
                this.updDenSo.Enabled = false;
                this.updSoLuong.Enabled = false;
                this.CKSoDuDK.Enabled = false;
                this.RadTruoc.Enabled = false;
                this.RadSau.Checked = true;
                this.RadSau.Enabled = false;
            }
            else
            {
                this.updTuSo.Enabled = true;
                this.updDenSo.Enabled = true;
                this.updSoLuong.Enabled = true;
                this.CKSoDuDK.Enabled = true;
                if (this.objDKHD.CheckThemTruoc(this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim()))
                {
                    this.RadTruoc.Enabled = true;
                    this.RadSau.Checked = true;
                    this.RadSau.Enabled = true;
                }
                else
                {
                    this.RadTruoc.Enabled = false;
                    this.RadSau.Checked = true;
                    this.RadSau.Enabled = false;
                }
                this.InitValue();
            }
        }

        public bool CheckIvalid()
        {
            if (this.CboLoaiHoaDon.SelectedIndex <= 0)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Chưa chọn loại h\x00f3a đơn !", ""));
                this.CboLoaiHoaDon.Focus();
                return false;
            }
            if (this.CboMauHoaDon.SelectedIndex <= 0)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Chưa chọn mẫu h\x00f3a đơn !", ""));
                this.CboMauHoaDon.Focus();
                return false;
            }
            if (this.CboSoKiHieu.SelectedIndex <= 0)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Chưa chọn k\x00fd hiệu !", ""));
                this.CboSoKiHieu.Focus();
                return false;
            }
            if (this.RadSau.Checked)
            {
                if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(LVYModule.Date2Char(this.dtpNgayBDSD.Text), this.strNgayKT, false) < 0)
                {
                    LVYModule.ShowWarning(modGeneral.Tranlated("Ng\x00e0y đăng k\x00fd phải bắt đầu từ ng\x00e0y ", "") + LVYModule.Char2Date(this.strNgayKT));
                    this.dtpNgayBDSD.Focus();
                    return false;
                }
            }
            else if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(LVYModule.Date2Char(this.dtpNgayBDSD.Text), this.strNgayKT, false) > 0)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Ng\x00e0y đăng k\x00fd phải nhỏ hơn hoặc bằng ng\x00e0y ", "") + LVYModule.Char2Date(this.strNgayKT));
                this.dtpNgayBDSD.Focus();
                return false;
            }
            return true;
        }

        private void CmdChon_Click(object sender, EventArgs e)
        {
            if (this.CheckIvalid())
            {
                try
                {
                    string str;
                    clsDangKyHoaDon objDKHD = this.objDKHD;
                    objDKHD.KhoaLoaiHoaDonIn = this.CboLoaiHoaDon.SelectedValue.ToString().Trim();
                    objDKHD.MauHoaDon = this.CboMauHoaDon.SelectedValue.ToString().Trim();
                    objDKHD.SoKiHieu = this.CboSoKiHieu.SelectedValue.ToString().Trim();
                    objDKHD.NgayBDSD = LVYModule.Date2Char(this.dtpNgayBDSD.Text);
                    objDKHD.SoLuong = Convert.ToDouble(this.updSoLuong.Value);
                    objDKHD.TuSo = Convert.ToDouble(this.updTuSo.Value);
                    objDKHD.DenSo = Convert.ToDouble(this.updDenSo.Value);
                    if (this.CKSoDuDK.CheckState == CheckState.Checked)
                    {
                        objDKHD.SoDuDK = 1;
                    }
                    else
                    {
                        objDKHD.SoDuDK = 0;
                    }
                    if (this.RadTruoc.Checked)
                    {
                        str = "T";
                    }
                    else
                    {
                        str = "S";
                    }
                    if (!objDKHD.Save(str))
                    {
                        return;
                    }
                    objDKHD = null;
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    MessageBox.Show(exception.Message.ToString());
                    ProjectData.ClearProjectError();
                    return;
                    ProjectData.ClearProjectError();
                }
                MyProject.Forms.Frm_DangKyHoaDonList.LoadData();
                this.Dispose();
            }
        }

        private void CmdThoat_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void Frm_DangKyHoaDon_Load(object sender, EventArgs e)
        {
            this.pData.Columns.Add("Ma", typeof(string));
            this.pData.Columns.Add("Ten", typeof(string));
            this.pData.Rows.Add(new object[] { "", "" });
            BuildComboModule.BuildCombo(this.CboLoaiHoaDon, modGeneral.ListDanhMuc.LoaiHoaDonIn, true, "", "");
            this.CboLoaiHoaDon.SelectedIndex = 1;
            this.CboLoaiHoaDon.Enabled = false;
            this.updTuSo.Enabled = false;
            this.updDenSo.Enabled = false;
            this.updSoLuong.Enabled = false;
            this.CKSoDuDK.Enabled = false;
            this.RadTruoc.Enabled = false;
            this.RadSau.Checked = true;
            this.RadSau.Enabled = false;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.C1DockingTab1 = new C1DockingTab();
            this.C1DockingTabPage1 = new C1DockingTabPage();
            this.RadSau = new RadioButton();
            this.RadTruoc = new RadioButton();
            this.CKSoDuDK = new CheckBox();
            this.updDenSo = new NumericUpDown();
            this.Label7 = new Label();
            this.updTuSo = new NumericUpDown();
            this.Label6 = new Label();
            this.updSoLuong = new NumericUpDown();
            this.Label5 = new Label();
            this.dtpNgayBDSD = new DateTimePicker();
            this.Label4 = new Label();
            this.CboSoKiHieu = new ComboBox();
            this.Label3 = new Label();
            this.CboMauHoaDon = new ComboBox();
            this.Label2 = new Label();
            this.CboLoaiHoaDon = new ComboBox();
            this.Label1 = new Label();
            this.Panel1 = new Panel();
            this.CmdThoat = new Button();
            this.CmdChon = new Button();
            ((ISupportInitialize) this.C1DockingTab1).BeginInit();
            this.C1DockingTab1.SuspendLayout();
            this.C1DockingTabPage1.SuspendLayout();
            this.updDenSo.BeginInit();
            this.updTuSo.BeginInit();
            this.updSoLuong.BeginInit();
            this.Panel1.SuspendLayout();
            this.SuspendLayout();
            this.C1DockingTab1.Controls.Add(this.C1DockingTabPage1);
            this.C1DockingTab1.Dock = DockStyle.Fill;
            Point point = new Point(0, 0);
            this.C1DockingTab1.Location = point;
            this.C1DockingTab1.Name = "C1DockingTab1";
            Size size = new Size(0x211, 0xd7);
            this.C1DockingTab1.Size = size;
            this.C1DockingTab1.TabIndex = 0;
            this.C1DockingTab1.TabsSpacing = 5;
            this.C1DockingTab1.TabStyle = TabStyleEnum.Office2007;
            this.C1DockingTab1.VisualStyle = VisualStyle.Office2007Blue;
            this.C1DockingTab1.VisualStyleBase = VisualStyle.Office2007Blue;
            this.C1DockingTabPage1.Controls.Add(this.RadSau);
            this.C1DockingTabPage1.Controls.Add(this.RadTruoc);
            this.C1DockingTabPage1.Controls.Add(this.CKSoDuDK);
            this.C1DockingTabPage1.Controls.Add(this.updDenSo);
            this.C1DockingTabPage1.Controls.Add(this.Label7);
            this.C1DockingTabPage1.Controls.Add(this.updTuSo);
            this.C1DockingTabPage1.Controls.Add(this.Label6);
            this.C1DockingTabPage1.Controls.Add(this.updSoLuong);
            this.C1DockingTabPage1.Controls.Add(this.Label5);
            this.C1DockingTabPage1.Controls.Add(this.dtpNgayBDSD);
            this.C1DockingTabPage1.Controls.Add(this.Label4);
            this.C1DockingTabPage1.Controls.Add(this.CboSoKiHieu);
            this.C1DockingTabPage1.Controls.Add(this.Label3);
            this.C1DockingTabPage1.Controls.Add(this.CboMauHoaDon);
            this.C1DockingTabPage1.Controls.Add(this.Label2);
            this.C1DockingTabPage1.Controls.Add(this.CboLoaiHoaDon);
            this.C1DockingTabPage1.Controls.Add(this.Label1);
            this.C1DockingTabPage1.Image = ACCOUNTING.My.Resources.Resources.Selected;
            point = new Point(1, 0x19);
            this.C1DockingTabPage1.Location = point;
            this.C1DockingTabPage1.Name = "C1DockingTabPage1";
            size = new Size(0x20f, 0xbd);
            this.C1DockingTabPage1.Size = size;
            this.C1DockingTabPage1.TabIndex = 0;
            this.C1DockingTabPage1.Text = "Th\x00f4ng tin đăng k\x00fd sử dụng h\x00f3a đơn";
            this.RadSau.AutoSize = true;
            this.RadSau.BackColor = Color.Transparent;
            this.RadSau.Checked = true;
            point = new Point(0x2a, 0x79);
            this.RadSau.Location = point;
            this.RadSau.Name = "RadSau";
            size = new Size(0xc0, 0x11);
            this.RadSau.Size = size;
            this.RadSau.TabIndex = 0x11;
            this.RadSau.TabStop = true;
            this.RadSau.Text = "Đăng k\x00fd sau số h\x00f3a đơn hiện h\x00e0nh";
            this.RadSau.UseVisualStyleBackColor = false;
            this.RadTruoc.AutoSize = true;
            this.RadTruoc.BackColor = Color.Transparent;
            point = new Point(0x29, 0x62);
            this.RadTruoc.Location = point;
            this.RadTruoc.Name = "RadTruoc";
            size = new Size(0xc7, 0x11);
            this.RadTruoc.Size = size;
            this.RadTruoc.TabIndex = 0x10;
            this.RadTruoc.Text = "Đăng k\x00fd trước số h\x00f3a đơn hiện h\x00e0nh";
            this.RadTruoc.UseVisualStyleBackColor = false;
            this.CKSoDuDK.AutoSize = true;
            this.CKSoDuDK.BackColor = Color.Transparent;
            point = new Point(0x15c, 0x79);
            this.CKSoDuDK.Location = point;
            this.CKSoDuDK.Name = "CKSoDuDK";
            size = new Size(90, 0x11);
            this.CKSoDuDK.Size = size;
            this.CKSoDuDK.TabIndex = 15;
            this.CKSoDuDK.Text = "Số dư đầu kỳ";
            this.CKSoDuDK.UseVisualStyleBackColor = false;
            point = new Point(0x15c, 0x5f);
            this.updDenSo.Location = point;
            decimal num = new decimal(new int[] { 0x98967f, 0, 0, 0 });
            this.updDenSo.Maximum = num;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.updDenSo.Minimum = num;
            this.updDenSo.Name = "updDenSo";
            size = new Size(0x79, 20);
            this.updDenSo.Size = size;
            this.updDenSo.TabIndex = 14;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.updDenSo.Value = num;
            this.Label7.AutoSize = true;
            this.Label7.BackColor = Color.Transparent;
            point = new Point(0x110, 0x61);
            this.Label7.Location = point;
            this.Label7.Name = "Label7";
            size = new Size(0x29, 13);
            this.Label7.Size = size;
            this.Label7.TabIndex = 13;
            this.Label7.Text = "Đến số";
            point = new Point(0x15d, 0x43);
            this.updTuSo.Location = point;
            num = new decimal(new int[] { 0x98967f, 0, 0, 0 });
            this.updTuSo.Maximum = num;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.updTuSo.Minimum = num;
            this.updTuSo.Name = "updTuSo";
            size = new Size(120, 20);
            this.updTuSo.Size = size;
            this.updTuSo.TabIndex = 12;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.updTuSo.Value = num;
            this.Label6.AutoSize = true;
            this.Label6.BackColor = Color.Transparent;
            point = new Point(0x110, 0x45);
            this.Label6.Location = point;
            this.Label6.Name = "Label6";
            size = new Size(0x22, 13);
            this.Label6.Size = size;
            this.Label6.TabIndex = 11;
            this.Label6.Text = "Từ số";
            point = new Point(0x15d, 0x24);
            this.updSoLuong.Location = point;
            num = new decimal(new int[] { 0x98967f, 0, 0, 0 });
            this.updSoLuong.Maximum = num;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.updSoLuong.Minimum = num;
            this.updSoLuong.Name = "updSoLuong";
            size = new Size(120, 20);
            this.updSoLuong.Size = size;
            this.updSoLuong.TabIndex = 10;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.updSoLuong.Value = num;
            this.Label5.AutoSize = true;
            this.Label5.BackColor = Color.Transparent;
            point = new Point(0x110, 0x26);
            this.Label5.Location = point;
            this.Label5.Name = "Label5";
            size = new Size(0x31, 13);
            this.Label5.Size = size;
            this.Label5.TabIndex = 9;
            this.Label5.Text = "Số lượng";
            this.dtpNgayBDSD.Format = DateTimePickerFormat.Short;
            point = new Point(0x15d, 8);
            this.dtpNgayBDSD.Location = point;
            this.dtpNgayBDSD.Name = "dtpNgayBDSD";
            size = new Size(0x79, 20);
            this.dtpNgayBDSD.Size = size;
            this.dtpNgayBDSD.TabIndex = 7;
            this.Label4.AutoSize = true;
            this.Label4.BackColor = Color.Transparent;
            point = new Point(0x110, 12);
            this.Label4.Location = point;
            this.Label4.Name = "Label4";
            size = new Size(0x4a, 13);
            this.Label4.Size = size;
            this.Label4.TabIndex = 6;
            this.Label4.Text = "Ng\x00e0y đăng k\x00fd";
            this.CboSoKiHieu.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboSoKiHieu.FormattingEnabled = true;
            point = new Point(0x73, 0x42);
            this.CboSoKiHieu.Location = point;
            this.CboSoKiHieu.Name = "CboSoKiHieu";
            size = new Size(0x79, 0x15);
            this.CboSoKiHieu.Size = size;
            this.CboSoKiHieu.TabIndex = 5;
            this.Label3.AutoSize = true;
            this.Label3.BackColor = Color.Transparent;
            point = new Point(0x26, 0x45);
            this.Label3.Location = point;
            this.Label3.Name = "Label3";
            size = new Size(0x2a, 13);
            this.Label3.Size = size;
            this.Label3.TabIndex = 4;
            this.Label3.Text = "K\x00fd hiệu";
            this.CboMauHoaDon.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboMauHoaDon.FormattingEnabled = true;
            point = new Point(0x73, 0x24);
            this.CboMauHoaDon.Location = point;
            this.CboMauHoaDon.Name = "CboMauHoaDon";
            size = new Size(0x79, 0x15);
            this.CboMauHoaDon.Size = size;
            this.CboMauHoaDon.TabIndex = 3;
            this.Label2.AutoSize = true;
            this.Label2.BackColor = Color.Transparent;
            point = new Point(0x26, 0x27);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x47, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 2;
            this.Label2.Text = "Mẫu h\x00f3a đơn";
            this.CboLoaiHoaDon.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboLoaiHoaDon.FormattingEnabled = true;
            point = new Point(0x72, 7);
            this.CboLoaiHoaDon.Location = point;
            this.CboLoaiHoaDon.Name = "CboLoaiHoaDon";
            size = new Size(0x79, 0x15);
            this.CboLoaiHoaDon.Size = size;
            this.CboLoaiHoaDon.TabIndex = 1;
            this.Label1.AutoSize = true;
            this.Label1.BackColor = Color.Transparent;
            point = new Point(0x26, 10);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(70, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 0;
            this.Label1.Text = "Loại h\x00f3a đơn";
            this.Panel1.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgleft;
            this.Panel1.Controls.Add(this.CmdThoat);
            this.Panel1.Controls.Add(this.CmdChon);
            this.Panel1.Dock = DockStyle.Bottom;
            point = new Point(0, 0xb3);
            this.Panel1.Location = point;
            this.Panel1.Name = "Panel1";
            size = new Size(0x211, 0x24);
            this.Panel1.Size = size;
            this.Panel1.TabIndex = 1;
            this.CmdThoat.Image = ACCOUNTING.My.Resources.Resources.Closed;
            this.CmdThoat.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x1b3, 4);
            this.CmdThoat.Location = point;
            this.CmdThoat.Name = "CmdThoat";
            size = new Size(0x4b, 0x1b);
            this.CmdThoat.Size = size;
            this.CmdThoat.TabIndex = 0;
            this.CmdThoat.Text = "&Tho\x00e1t";
            this.CmdThoat.UseVisualStyleBackColor = true;
            this.CmdChon.Image = ACCOUNTING.My.Resources.Resources.Selected;
            this.CmdChon.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(350, 4);
            this.CmdChon.Location = point;
            this.CmdChon.Name = "CmdChon";
            size = new Size(0x4b, 0x1b);
            this.CmdChon.Size = size;
            this.CmdChon.TabIndex = 0;
            this.CmdChon.Text = "&Chọn";
            this.CmdChon.UseVisualStyleBackColor = true;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x211, 0xd7);
            this.ClientSize = size;
            this.Controls.Add(this.Panel1);
            this.Controls.Add(this.C1DockingTab1);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Frm_DangKyHoaDon";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "DANG KY HOA DON";
            ((ISupportInitialize) this.C1DockingTab1).EndInit();
            this.C1DockingTab1.ResumeLayout(false);
            this.C1DockingTabPage1.ResumeLayout(false);
            this.C1DockingTabPage1.PerformLayout();
            this.updDenSo.EndInit();
            this.updTuSo.EndInit();
            this.updSoLuong.EndInit();
            this.Panel1.ResumeLayout(false);
            this.ResumeLayout(false);
        }

        public void InitValue()
        {
            if (!(((this.CboLoaiHoaDon.SelectedIndex <= 0) | (this.CboMauHoaDon.SelectedIndex <= 0)) | (this.CboSoKiHieu.SelectedIndex <= 0)))
            {
                string str;
                if (this.RadSau.Checked)
                {
                    int num = this.objDKHD.GetTuSo(this.CboLoaiHoaDon.SelectedValue.ToString().Trim(), this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim());
                    if (num > 0x98967f)
                    {
                        LVYModule.ShowWarning("Số h\x00f3a đơn tối đa l\x00e0 9999999 ! Vui l\x00f2ng chọn k\x00fd hiệu kh\x00e1c!");
                        this.CboSoKiHieu.SelectedIndex = 0;
                        return;
                    }
                    this.updTuSo.Value = new decimal(num);
                    if (decimal.Compare(this.updTuSo.Value, decimal.One) != 0)
                    {
                        this.updTuSo.Enabled = false;
                    }
                    else
                    {
                        this.updTuSo.Enabled = true;
                    }
                    this.updDenSo.Enabled = true;
                    if (this.objDKHD.GetSoDuDK(this.CboLoaiHoaDon.SelectedValue.ToString().Trim(), this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim(), "S") > 0)
                    {
                        this.CKSoDuDK.Checked = false;
                        this.CKSoDuDK.Enabled = false;
                    }
                    else
                    {
                        this.CKSoDuDK.Checked = false;
                        this.CKSoDuDK.Enabled = true;
                    }
                    str = this.objDKHD.GetNgayBDSD(this.CboLoaiHoaDon.SelectedValue.ToString().Trim(), this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim(), "S");
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(LVYModule.ReturnIfNull(str, "", modGeneral.TypeOfValue.Nothing), "", false) && (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(str, LVYModule.Date2Char(this.dtpNgayBDSD.Text), false) > 0))
                    {
                        this.dtpNgayBDSD.Value = Conversions.ToDate(LVYModule.Char2Date(str));
                    }
                }
                else
                {
                    this.updDenSo.Value = new decimal(this.objDKHD.GetDenSo(this.CboLoaiHoaDon.SelectedValue.ToString().Trim(), this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim()));
                    this.updDenSo.Enabled = false;
                    this.updTuSo.Value = decimal.One;
                    this.updTuSo.Maximum = this.updDenSo.Value;
                    this.updSoLuong.Maximum = this.updDenSo.Value;
                    this.updTuSo.Enabled = true;
                    if (this.objDKHD.GetSoDuDK(this.CboLoaiHoaDon.SelectedValue.ToString().Trim(), this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim(), "T") <= 0)
                    {
                        this.CKSoDuDK.Checked = false;
                        this.CKSoDuDK.Enabled = true;
                    }
                    else
                    {
                        this.CKSoDuDK.Checked = false;
                        this.CKSoDuDK.Enabled = false;
                    }
                    str = this.objDKHD.GetNgayBDSD(this.CboLoaiHoaDon.SelectedValue.ToString().Trim(), this.CboMauHoaDon.SelectedValue.ToString().Trim(), this.CboSoKiHieu.SelectedValue.ToString().Trim(), "T");
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(LVYModule.ReturnIfNull(str, "", modGeneral.TypeOfValue.Nothing), "", false))
                    {
                        this.dtpNgayBDSD.Value = Conversions.ToDate(LVYModule.Char2Date(str));
                    }
                }
                this.strNgayKT = str;
            }
        }

        private void Label4_Click(object sender, EventArgs e)
        {
        }

        private void RadSau_CheckedChanged(object sender, EventArgs e)
        {
            this.updSoLuong.Minimum = decimal.One;
            this.updSoLuong.Maximum = 9999999M;
            this.updTuSo.Minimum = decimal.One;
            this.updTuSo.Maximum = 9999999M;
            this.updDenSo.Minimum = decimal.One;
            this.updDenSo.Maximum = 9999999M;
            this.InitValue();
        }

        private void RadTruoc_CheckedChanged(object sender, EventArgs e)
        {
            this.updSoLuong.Minimum = decimal.One;
            this.updSoLuong.Maximum = 9999999M;
            this.updTuSo.Minimum = decimal.One;
            this.updTuSo.Maximum = 9999999M;
            this.updDenSo.Minimum = decimal.One;
            this.updDenSo.Maximum = 9999999M;
            this.InitValue();
        }

        private void updDenSo_ValueChanged(object sender, EventArgs e)
        {
            if (this.RadSau.Checked)
            {
                this.updSoLuong.Value = decimal.Add(decimal.Subtract(this.updDenSo.Value, this.updTuSo.Value), decimal.One);
            }
            else
            {
                this.updTuSo.Maximum = this.updDenSo.Value;
            }
        }

        private void updSoLuong_ValueChanged(object sender, EventArgs e)
        {
            if (this.RadSau.Checked)
            {
                this.updDenSo.Value = decimal.Subtract(decimal.Add(this.updTuSo.Value, this.updSoLuong.Value), decimal.One);
            }
            else
            {
                this.updTuSo.Value = decimal.Add(decimal.Subtract(this.updDenSo.Value, this.updSoLuong.Value), decimal.One);
            }
        }

        private void updTuSo_ValueChanged(object sender, EventArgs e)
        {
            if (this.RadSau.Checked)
            {
                this.updDenSo.Minimum = this.updTuSo.Value;
                this.updDenSo.Value = decimal.Subtract(decimal.Add(this.updTuSo.Value, this.updSoLuong.Value), decimal.One);
            }
            else if (decimal.Compare(this.updTuSo.Value, this.updTuSo.Maximum) <= 0)
            {
                this.updSoLuong.Value = decimal.Add(decimal.Subtract(this.updDenSo.Value, this.updTuSo.Value), decimal.One);
            }
        }

        internal virtual C1DockingTab C1DockingTab1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._C1DockingTab1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._C1DockingTab1 = value;
            }
        }

        internal virtual C1DockingTabPage C1DockingTabPage1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._C1DockingTabPage1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._C1DockingTabPage1 = value;
            }
        }

        internal virtual ComboBox CboLoaiHoaDon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboLoaiHoaDon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboLoaiHoaDon_SelectedIndexChanged);
                if (this._CboLoaiHoaDon != null)
                {
                    this._CboLoaiHoaDon.SelectedIndexChanged -= handler;
                }
                this._CboLoaiHoaDon = value;
                if (this._CboLoaiHoaDon != null)
                {
                    this._CboLoaiHoaDon.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboMauHoaDon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboMauHoaDon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboMauHoaDon_SelectedIndexChanged);
                if (this._CboMauHoaDon != null)
                {
                    this._CboMauHoaDon.SelectedIndexChanged -= handler;
                }
                this._CboMauHoaDon = value;
                if (this._CboMauHoaDon != null)
                {
                    this._CboMauHoaDon.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboSoKiHieu
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboSoKiHieu;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboSoKiHieu_SelectedIndexChanged);
                if (this._CboSoKiHieu != null)
                {
                    this._CboSoKiHieu.SelectedIndexChanged -= handler;
                }
                this._CboSoKiHieu = value;
                if (this._CboSoKiHieu != null)
                {
                    this._CboSoKiHieu.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual CheckBox CKSoDuDK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CKSoDuDK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CKSoDuDK = value;
            }
        }

        internal virtual Button CmdChon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdChon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdChon_Click);
                if (this._CmdChon != null)
                {
                    this._CmdChon.Click -= handler;
                }
                this._CmdChon = value;
                if (this._CmdChon != null)
                {
                    this._CmdChon.Click += handler;
                }
            }
        }

        internal virtual Button CmdThoat
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdThoat;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdThoat_Click);
                if (this._CmdThoat != null)
                {
                    this._CmdThoat.Click -= handler;
                }
                this._CmdThoat = value;
                if (this._CmdThoat != null)
                {
                    this._CmdThoat.Click += handler;
                }
            }
        }

        internal virtual DateTimePicker dtpNgayBDSD
        {
            [DebuggerNonUserCode]
            get
            {
                return this._dtpNgayBDSD;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._dtpNgayBDSD = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label3 = value;
            }
        }

        internal virtual Label Label4
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label4;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.Label4_Click);
                if (this._Label4 != null)
                {
                    this._Label4.Click -= handler;
                }
                this._Label4 = value;
                if (this._Label4 != null)
                {
                    this._Label4.Click += handler;
                }
            }
        }

        internal virtual Label Label5
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label5;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label5 = value;
            }
        }

        internal virtual Label Label6
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label6;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label6 = value;
            }
        }

        internal virtual Label Label7
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label7;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label7 = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual RadioButton RadSau
        {
            [DebuggerNonUserCode]
            get
            {
                return this._RadSau;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.RadSau_CheckedChanged);
                if (this._RadSau != null)
                {
                    this._RadSau.CheckedChanged -= handler;
                }
                this._RadSau = value;
                if (this._RadSau != null)
                {
                    this._RadSau.CheckedChanged += handler;
                }
            }
        }

        internal virtual RadioButton RadTruoc
        {
            [DebuggerNonUserCode]
            get
            {
                return this._RadTruoc;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.RadTruoc_CheckedChanged);
                if (this._RadTruoc != null)
                {
                    this._RadTruoc.CheckedChanged -= handler;
                }
                this._RadTruoc = value;
                if (this._RadTruoc != null)
                {
                    this._RadTruoc.CheckedChanged += handler;
                }
            }
        }

        internal virtual NumericUpDown updDenSo
        {
            [DebuggerNonUserCode]
            get
            {
                return this._updDenSo;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.updDenSo_ValueChanged);
                if (this._updDenSo != null)
                {
                    this._updDenSo.ValueChanged -= handler;
                }
                this._updDenSo = value;
                if (this._updDenSo != null)
                {
                    this._updDenSo.ValueChanged += handler;
                }
            }
        }

        internal virtual NumericUpDown updSoLuong
        {
            [DebuggerNonUserCode]
            get
            {
                return this._updSoLuong;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.updSoLuong_ValueChanged);
                if (this._updSoLuong != null)
                {
                    this._updSoLuong.ValueChanged -= handler;
                }
                this._updSoLuong = value;
                if (this._updSoLuong != null)
                {
                    this._updSoLuong.ValueChanged += handler;
                }
            }
        }

        internal virtual NumericUpDown updTuSo
        {
            [DebuggerNonUserCode]
            get
            {
                return this._updTuSo;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.updTuSo_ValueChanged);
                if (this._updTuSo != null)
                {
                    this._updTuSo.ValueChanged -= handler;
                }
                this._updTuSo = value;
                if (this._updTuSo != null)
                {
                    this._updTuSo.ValueChanged += handler;
                }
            }
        }
    }
}

